using System;
using System.Collections.Generic;
using System.Text;

using NHibernate;
using Zwms.Data.BusinessObjects;
using Zwms.Data.Base;

namespace Zwms.Data.ManagerObjects
{
    public partial interface ISysAccountManager : IManagerBase<Zwms.Data.BusinessObjects.SysAccount, string>
    {
        SysAccount GetAccountByUserCode(string sUsercode);
	}

    partial class SysAccountManager : ManagerBase<Zwms.Data.BusinessObjects.SysAccount, string>, ISysAccountManager
    {
        #region Constructors

        public SysAccountManager()
            : base()
        {
        }
        public SysAccountManager(INHibernateSession session)
            : base(session)
        {
        }

        #endregion

        #region Get Methods
        public SysAccount GetAccountByUserCode(string sUsercode)
        {
            ICriteria criteria = Session.GetISession().CreateCriteria(typeof(SysAccount));

            criteria.Add(NHibernate.Criterion.Expression.Eq("UserCode", sUsercode));

            SysAccount result = (SysAccount)criteria.UniqueResult();

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
        }
 
        #endregion
	}
}